//
//  CsutomMapAnnotationView.m
//  CityFire
//
//  Created by liuyangzhu on 2017/9/15.
//  Copyright © 2017年 刘养柱. All rights reserved.
//

#import "CsutomMapAnnotationView.h"

#define kCalloutWidth       120
#define kCalloutHeight      45

@interface CsutomMapAnnotationView ()

@property (nonatomic, strong, readwrite) CustomMapCalloutView *calloutView;

@end

@implementation CsutomMapAnnotationView

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    if (self.selected == selected)
    {
        return;
    }
    
    if (selected)
    {
        if (self.calloutView == nil)
        {
            self.calloutView = [[CustomMapCalloutView alloc] initWithFrame:CGRectMake(0, 0, kCalloutWidth, kCalloutHeight)];
            self.calloutView.center = CGPointMake(CGRectGetWidth(self.bounds) / 2.f + self.calloutOffset.x,
                                                  -CGRectGetHeight(self.calloutView.bounds) / 2.f + self.calloutOffset.y);
        }
        
//        self.calloutView.image = [UIImage imageNamed:@"building"];
        self.calloutView.title = self.annotation.title;
//        self.calloutView.title = @"sfjjsdflflfj";
//        self.calloutView.subtitle = self.annotation.subtitle;
        
        [self addSubview:self.calloutView];
    }
    else
    {
        [self.calloutView removeFromSuperview];
    }
    
    [super setSelected:selected animated:animated];
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
